<%--
  Created by IntelliJ IDEA.
  User: ZTencent
  Date: 2022/12/29
  Time: 10:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/html5.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/respond.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/PIE_IE678.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/Widget/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/Widget/ueditor/1.4.3/ueditor.all.js"> </script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/Widget/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
    <![endif]-->
    <link href="${pageContext.request.contextPath}/statics/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/style.css"/>
    <link href="${pageContext.request.contextPath}/statics/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/Widget/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome.min.css" />
    <!--[if IE 7]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome-ie7.min.css" />
    <![endif]-->
    <link href="${pageContext.request.contextPath}/statics/Widget/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/statics/Widget/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
    <style>
        #container{
            width: 100%;
            height: 500px;
        }
    </style>
    <title>商家注册</title>
</head>
<body>
<div class="clearfix " id="add_picture">
    <div class="container-fluid" style="height: 100px;box-shadow: 2px 2px 3px rgba(125,125,125,0.7);margin-bottom: 30px">

        <div class="row">
            <div class="col-md-1 col-md-offset-1"><img src="${pageContext.request.contextPath}/statics/images/logo.png"/></div>
            <div class="col-md-3"><h1  style="line-height: 100px">千锋外卖商户注册</h1></div>
        </div>
    </div>
    <div class="page_center_style container">
        <div class="type_title text-center"><h1>注册商家</h1></div>
        <form action="${pageContext.request.contextPath}/business/register" method="post" enctype="multipart/form-data" class="form form-horizontal" id="form-article-add">
            <div class="clearfix cl">
                <label class="form-label col-2"><span class="c-red"></span>商家名称：</label>
                <div class="formControls col-10"><input type="text" class="input-text" value="" placeholder="" id="" name="bname"></div>
            </div>
            <div class=" clearfix cl">
                <label class="form-label col-2">商家电话：</label>
                <div class="formControls col-10"><input type="text" class="input-text" value="" placeholder="" id="" name="phone"></div>
            </div>
            <div class=" clearfix cl">

                <div class="Add_p_s">
                    <label class="form-label col-2">商家登录名：</label>
                    <div class="formControls col-2"><input type="text" class="input-text" value="" placeholder="" id="" name="bloginName"></div>
                </div>
                <div class="Add_p_s">
                    <label class="form-label col-2">商家密码：</label>
                    <div class="formControls col-2"><input type="text" class="input-text" value="" placeholder="" id="" name="bloginPwd"></div>
                </div>
                <div class="Add_p_s">
                    <label class="form-label col-2">配送时段：</label>
                    <div class="formControls col-2"><input type="text" class="input-text" value="" placeholder="" id="" name="btimeSlot"></div>
                </div>

                <div class="Add_p_s">
                    <label class="form-label col-2">商家类型：</label>
                    <div class="formControls col-2"><span class="select-box">
				<select class="select" name="mcId">
					<c:forEach var="mc" items="${mcs}">
                        <option value="${mc.mcId}">${mc.mcName}</option>
                    </c:forEach>
				</select>
				</span></div>
                </div>

                <div class="Add_p_s">
                    <label class="form-label col-2">省/直辖市：</label>
                    <div class="formControls col-2"><span class="select-box">
				<select class="select" id="pro">
                    <c:forEach var="p" items="${province}">
					    <option value="${p.adCode}">${p.cityName}</option>
                    </c:forEach>

				</select>
				</span></div>
                </div>

                <div class="Add_p_s">
                    <label class="form-label col-2">市/区：</label>
                    <div class="formControls col-2"><span class="select-box">
				<select class="select" id="city">
                    <option value="1">餐饮</option>
					<option value="2">超市</option>
					<option value="3">蔬菜水果</option>
					<option value="4">药店</option>
				</select>
				</span></div>
                </div>
                <div class="Add_p_s">
                    <label class="form-label col-2">区/县：</label>
                    <div class="formControls col-2"><span class="select-box">
				<select class="select" id="area" name="adCode">
                    <option value="1">餐饮</option>
					<option value="2">超市</option>
					<option value="3">蔬菜水果</option>
					<option value="4">药店</option>
				</select>
				</span></div>
                </div>
                <div class="Add_p_s">
                    <label class="form-label col-2">经纬度：</label>
                    <div class="formControls col-2"><input type="text" class="input-text" value="" placeholder=""  id="lonlat" style="width: 240px" >
                    <input type="hidden" name="log" id="log"/><br><input type="hidden" name="lat" id="lat"/>
                    </div>
                </div>
            </div>
            <div class=" clearfix cl">
                <label class="form-label col-2">详细地址：</label>
                <div class="formControls col-10"><input type="text" class="input-text" value="" placeholder="" id="address" name="address"></div>
            </div>
            <div class=" clearfix cl">
                <div id="container"></div>
            </div>
            <div class="clearfix cl">
                <label class="form-label col-2">图片上传：</label>
                <div class="formControls col-10">
                    <input type="file" name="bimgs" multiple="multiple"/>
                </div>
            </div>
            <div class="clearfix cl">
                <label class="form-label col-2">资质上传：</label>
                <div class="formControls col-10">
                    <input type="file" name="qts" multiple="multiple"/>
                </div>
            </div>
            <div class="clearfix cl">
                <label class="form-label col-2">详细内容：</label>
                <div class="formControls col-10">
                    <script id="editor" name="bdesc" type="text/plain" charset="utf-8"  style="width:100%;height:400px;"></script>
                    <script>
                        UE.getEditor("editor");
                    </script>
                </div>
            </div>

            <div class="clearfix cl">
                <div class="Button_operation">
                    <button class="btn btn-primary radius" type="submit"><i class="icon-save "></i>提交审核</button>
                </div>
            </div>
        </form>
    </div>
</div>
</div>
<script src="${pageContext.request.contextPath}/statics/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/assets/layer/layer.js"></script>
<script type="text/javascript">
    window._AMapSecurityConfig = {
        securityJsCode:'18fb86c88fbe6b3be721dd9976cc47c5',
    }
</script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=4dfa3c3a75b41baa0c38be9e1374b358&plugin=AMap.Geocoder"></script>

<script>
    $(function () {
        // UE.getEditor("editor");
        //卫星图层
        var satellite=new AMap.TileLayer.Satellite();
        //路网图层
        var roadNet=new AMap.TileLayer.RoadNet();
        //实时交通
        var traffic=new AMap.TileLayer.Traffic();
        var map=new AMap.Map("container",{
            zoom:12,//级别
            viewMode:'3D',//使用3D视图
            layers:[satellite,roadNet,traffic]
        });
        var geocoder = new AMap.Geocoder();
        var oldMarker;
        map.on("click",function (e) {
            // 将 Icon 实例添加到 marker 上:
            var marker=new AMap.Marker({
                position:new AMap.LngLat(e.lnglat.getLng(),e.lnglat.getLat())

            });
            $("#lonlat").val(e.lnglat.getLng()+","+e.lnglat.getLat());
            $("#log").val(e.lnglat.getLng());
            $("#lat").val(e.lnglat.getLat());
            geocoder.getAddress(e.lnglat,function(status,result){
                if (status === 'complete' && result.info === 'OK') {
                    //result.regeocode.formattedAddress根据给指的经纬度来换取对应的地址信息
                    $("#address").val(result.regeocode.formattedAddress);
                }
            });
            map.add(marker);
            if(oldMarker!=null){
                map.remove(oldMarker);
            }
            oldMarker=marker;
        })
        $("#address").on("blur",function () {

            var address=$(this).val();

            geocoder.getLocation(address, function(status, result) {
                if (status === 'complete' && result.info === 'OK') {
                    // result中对应详细地理坐标信息
                    if (status === 'complete' && result.info === 'OK') {
                        var arr=result.geocodes;  //地理位置对象  数组
                        for(var i in arr){
                            $("#lnglat").val(arr[i].location);
                            map=new AMap.Map("container",{
                                zoom:18,
                                center:arr[i].location,
                                viewMode:"3D",
                                layers:[satellite,roadNet,traffic]
                            });
                            var marker=new AMap.Marker({
                                position:arr[i].location
                            });
                            map.add(marker);
                            oldMarker=marker;
                            map.on("click",function (e) {
                                // 将 Icon 实例添加到 marker 上:
                                marker=new AMap.Marker({
                                    position:new AMap.LngLat(e.lnglat.getLng(),e.lnglat.getLat())

                                });
                                $("#lonlat").val(e.lnglat.getLng()+","+e.lnglat.getLat());
                                $("input[name='log']").val(e.lnglat.getLng());
                                $("input[name='lat']").val(e.lnglat.getLat());
                                geocoder.getAddress(e.lnglat,function(status,result){
                                    if (status === 'complete' && result.info === 'OK') {
                                        //result.regeocode.formattedAddress根据给指的经纬度来换取对应的地址信息
                                        $("#address").val(result.regeocode.formattedAddress);
                                    }
                                });
                                map.add(marker);
                                if(oldMarker!=null){
                                    map.remove(oldMarker);
                                }
                                oldMarker=marker;
                            })
                            $("#lonlat").val(arr[i].location);

                        }
                    }else {
                        log.error("没有找到这个地方");
                    }
                }
            })
        })


    })

</script>
<script>
    $(function () {
        loadcicty();
        $("#pro").change(function () {
            loadcicty();

        })
        $("#city").change(function () {
            loadarea()
        })
    })
    function loadcicty() {
        $.getJSON("${pageContext.request.contextPath}/city/querycity",{"id":$("#pro").val()},function (e) {
            $("#city option").remove();
            console.log(e.data);
            var data = e.data;
            for (var i=0;i< data.length;i++){
                $("#city").append(new Option(data[i].cityName,data[i].adCode));
            }
            loadarea();
        })
    }
    function loadarea() {
        $.getJSON("${pageContext.request.contextPath}/city/queryarea",{"citycode":$("#city").val()},function (e) {
            $("#area option").remove();
            console.log(e.data);
            var data = e.data;
            for (var i=0;i< data.length;i++){
                $("#area").append(new Option(data[i].cityName,data[i].adCode));
            }
        })
    }
</script>
</body>
</html>
